package com.sunbird.crm.base.configurate.mvc;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.springframework.web.servlet.view.InternalResourceViewResolver;

/**
 * @ClassName WebAppConfigure
 * @Descriptiom TODO
 * @Author Sunbird 视图解析器
 * @Date 2019/8/24 17:57
 * @Version 1.0
 **/
//@Configuration
//@EnableWebMvc
public class WebAppConfigure implements WebMvcConfigurer {

    @Bean
    public InternalResourceViewResolver viewResolver(){
        InternalResourceViewResolver viewResolver =new InternalResourceViewResolver();
        viewResolver.setPrefix("resources/views/");
        viewResolver.setSuffix(".html");
        return viewResolver;
    }

    public  void addViewContorollers(ViewControllerRegistry registration){
        WebMvcConfigurer.super.addViewControllers(registration);
        registration.addViewController("/").setViewName("index");
        registration.setOrder(Ordered.HIGHEST_PRECEDENCE);
    }
}
